﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJASPX.Service;
using log4net;
using NHibernate.Criterion;


namespace PlugNT.Cms.Web
{
    public partial class Company : System.Web.UI.Page
    {
        public long TotalCount = 0;

        public int PageSize = 12;

        private static readonly ILog logger = LogManager.GetLogger(typeof(Ent));

        public IUserService iUserService { get; set; }

        public IProductService iProductService { get; set; }

        public IList<FJASPX.Domain.User> UserList { get; set; }

        public IList<FJASPX.Domain.Product> ProductList { get; set; }

        protected void Page_Load(object sender, EventArgs e)
        {
            Bind();
        }
        private void Bind()
        {
            try
            {
                int indexPage = 0;
                if (!string.IsNullOrEmpty(Request.QueryString["page"]))
                {
                    indexPage = Convert.ToInt32(Request.QueryString["Page"]);
                }
                ICriterion criterion = Expression.Sql("Type=0 and State=0 and Commend=1");
                List<Order> orders = new List<Order>();
                orders.Add(new Order("Id", false));
                this.UserList = iUserService.PagedQuery(criterion, orders, indexPage, PageSize, out TotalCount);

                ICriterion criterion1 = Expression.Sql("Pro_State&2=2");//热门
                long totalCount = 0;
                this.ProductList = iProductService.PagedQuery(criterion1, null, 0, 8, out totalCount);
            }
            catch (Exception ex)
            {
                logger.Error(ex);
            }
        }

        public string ReplaceTitle(string title)
        {
            if (title != null)
            {
                if (!string.IsNullOrEmpty(Request.QueryString["key"]))
                {
                    string key = Request.QueryString["key"].ToString();
                    title = title.Replace(key, "<font color=\"#ab3e05\">" + key + "</font>");
                }
                return title;
            }
            return string.Empty;
        }
    }
}